package cn.sample.moreitems;

import cn.sample.moreitems.client.ClientSetup;
import cn.sample.moreitems.init.*;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(MoreItems.MODID)
public class MoreItems {

    // Define mod id in a common place for everything to reference
    public static final String MODID = "moreitems";



    public MoreItems(FMLJavaModLoadingContext context) {
        IEventBus modEventBus = context.getModEventBus();

        // Register the Deferred Register to the mod event bus so blocks get registered
        ModEntities.ENTITIES.register(modEventBus);
        ModEntities.BLOCK_ENTITIES.register(modEventBus);
        // Register the Deferred Register to the mod event bus so items get registered
        ModItems.ITEMS.register(modEventBus);

        ModBlocks.BLOCKS.register(modEventBus);
        ModMenu.MENU_TYPES.register(modEventBus);

        ModParticles.PARTICLES.register(modEventBus);

        // Register the Deferred Register to the mod event bus so tabs get registered
        modEventBus.addListener(ClientSetup::init);

        modEventBus.addListener(this::addCreative);

        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);

    }

    // Add the example block item to the building blocks tab
    private void addCreative(BuildCreativeModeTabContentsEvent event) {
        if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS) {
            event.accept(ModItems.THROWN_ROCK);
            event.accept(ModItems.TECHNOLOGY_BLOCK);
            event.accept(ModItems.XUAN_YUAN_SWORD_ITEM);
        };
    }


}
